﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using System.Xml.Linq;
using ThangNM_LIB.FUNC;
using Facebook;
using EntityObject;
using DataAccessObject;
using System.Text.RegularExpressions;
using System.Timers;
using System.Threading.Tasks;

namespace FacebookApp.SharedLibraries
{
    public class ScheduleJobs
    {
        public static Boolean bWaiting;
        public static Int16 iThread_Count;

        ///// <summary>
        ///// Các công việc sau sẽ được tự động thực hiện sau 3 phút:
        /////     - Gọi hàm gửi mail khi có người đăng nhập, bình luận ở mục hỏi đáp.
        /////     - Gọi hàm kiểm tra thay đổi và tạo lại các file: sitemap.html, sitemap.xml, rss.xml.
        ///// </summary>
        ///// <param name="source"></param>
        ///// <param name="e"></param>
        //public static String Job_Frequency_3m(object source, System.Timers.ElapsedEventArgs e)
        //{
        //    //File.ReadAllText("C:\\Users\\Administrator\\Desktop\\FB\\feed.txt");//
        //    String sRet = "OK";
        //    try
        //    {
        //        if (!bWaiting)
        //        {
        //            bWaiting = true;

        //            //Step 1.0: Init
        //            FacebookClient FBClient = new FacebookClient();
        //            FBClient.AppId = OtherEx.getAppSettings("Facebook_AppId");
        //            FBClient.AppSecret = OtherEx.getAppSettings("Facebook_AppSecret");
        //            //FBClient.Version = OtherEx.getAppSettings("Version");

        //            //Step 1.1: Declare
        //            Boolean isNextPage = false;

        //            String strJson = "";
        //            String strQuery = "";

        //            List<OptionEXEO> lstFB_Page = new List<OptionEXEO>();
        //            FacebookEO.Feed objFB_Feed;
        //            FacebookEO.Post objFB_Post;
        //            FacebookEO.User objFB_User;
        //            Facebook_EXEO.User.accounts objFB_User_accounts;
        //            FacebookEO.Page objFB_Page;
        //            FacebookEO.Likes objFB_Like;
        //            FacebookEO.Comments objFB_Comment;
        //            FacebookEO.Comments objFB_Reply;

        //            AccountEO _AccountEO = new AccountEO();
        //            _AccountEO.PK_iAID = 1;
        //            PageEO _PageEO;
        //            PostEO _PostEO;
        //            LikeEO _LikeEO;
        //            CommentEO _CommentEO;
        //            OptionEO _OptionEO;
        //            UserEO _UserEO;


        //            //Step 1.2: Get token
        //            //if (String.IsNullOrEmpty(_AccountEO.sFToken))
        //            //    throw new Exception("Facebook token is null.");
        //            //FBClient.AccessToken = _AccountEO.sFToken;



        //            //Step 2.0: Get info [Account] in Database
        //            _AccountEO = (new AccountDAO()).SelectItem(_AccountEO);
        //            FBClient.AccessToken = _AccountEO.sFToken;

        //            //Step 2.1: Get info [User] in Facebook
        //            strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._x_yz, Constants.Facebook_Param.me, Constants.Facebook_Param.user_param, ""));
        //            objFB_User = new FacebookEO.User();
        //            objFB_User = (FacebookEO.User)JsonEx.Json2Object(strJson, objFB_User.GetType());
        //            if (CommonsCheck.Object_OK(objFB_User))
        //            {
        //                _UserEO = new UserEO(Convert.ToInt64(objFB_User.id), objFB_User.first_name, objFB_User.last_name, objFB_User.link, objFB_User.middle_name, objFB_User.name, objFB_User.timezone, Convert.ToDateTime(objFB_User.updated_time), objFB_User.verified, 0);
        //                (new UserDAO()).Insert_Update_Delete(_UserEO, ConstEx.Insert_Update_Delete.Insert);

        //                //Step 2.2: Get all [Page] of [User]
        //                strQuery = String.Format(Constants.Facebook_Option._x_yz, Constants.Facebook_Param.me, Constants.Facebook_Param.user_accounts, "");
        //                do
        //                {
        //                    strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                    objFB_User_accounts = new Facebook_EXEO.User.accounts();
        //                    objFB_User_accounts = (Facebook_EXEO.User.accounts)JsonEx.Json2Object(strJson, objFB_User_accounts.GetType());
        //                    if (objFB_User_accounts != null && CommonsCheck.ListObject_OK(objFB_User_accounts.data))
        //                        foreach (var itemFB_User in objFB_User_accounts.data)
        //                        {
        //                            _OptionEO = new OptionEO(Constants.Option_tid.user_page, Convert.ToInt64(objFB_User.id), Convert.ToInt64(itemFB_User.id), objFB_User.name, itemFB_User.name, itemFB_User.access_token, true, DateTime.Now, DateTime.Now, 0);
        //                            (new OptionDAO()).Insert_Update_Delete(_OptionEO, ConstEx.Insert_Update_Delete.Insert);
        //                        }
        //                    if (CommonsCheck.Object_OK(objFB_User_accounts) && CommonsCheck.Object_OK(objFB_User_accounts.paging) && !String.IsNullOrEmpty(objFB_User_accounts.paging.next))
        //                    {
        //                        isNextPage = true;
        //                        strQuery = StringEx.Trim(objFB_User_accounts.paging.next).Substring(32);
        //                    }
        //                    else
        //                        isNextPage = false;
        //                } while (isNextPage);
        //            }

        //            //Step 2.3: Get token [Page] in Database
        //            DataTable dt = (new OptionDAO()).SelectBy_tid_lid_rid(Constants.Option_tid.user_page, 0, 0, Constants.Option_iTypeSearch.get_all_page_scan);
        //            lstFB_Page = (List<OptionEXEO>)ConvertEx.ConvertDataTableToListObject<OptionEXEO>(dt, lstFB_Page.GetType());
        //            if (CommonsCheck.ListObject_OK(lstFB_Page))
        //            {
        //                foreach (OptionEXEO itemFB_Page in lstFB_Page)
        //                {
        //                    if (String.IsNullOrEmpty(itemFB_Page.sFToken))
        //                        continue;
        //                    else
        //                        FBClient.AccessToken = itemFB_Page.sFToken;

        //                    //Step 2.4: Insert/Update [Page]
        //                    strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._x, itemFB_Page.iFID));
        //                    objFB_Page = new FacebookEO.Page();
        //                    objFB_Page = (FacebookEO.Page)JsonEx.Json2Object(strJson, objFB_Page.GetType());
        //                    if (CommonsCheck.Object_OK(objFB_Page))
        //                    {
        //                        _PageEO = new PageEO(Convert.ToInt64(objFB_Page.id), objFB_Page.about, ConvertEx.StringFB2DateTime(objFB_Page.birthday, "MM/dd/yyyy"), objFB_Page.can_post, objFB_Page.category, objFB_Page.checkins, objFB_Page.country_page_likes, JsonEx.Object2Json(objFB_Page.cover), objFB_Page.description, objFB_Page.has_added_app, objFB_Page.is_community_page, objFB_Page.is_published, objFB_Page.new_like_count, objFB_Page.likes, objFB_Page.link, objFB_Page.name, objFB_Page.offer_eligible, JsonEx.Object2Json(objFB_Page.parking), objFB_Page.promotion_eligible, objFB_Page.talking_about_count, objFB_Page.unread_message_count, objFB_Page.unread_notif_count, objFB_Page.unseen_message_count, objFB_Page.username, objFB_Page.website, objFB_Page.were_here_count, 0);
        //                        (new PageDAO()).Insert_Update_Delete(_PageEO, ConstEx.Insert_Update_Delete.Insert);
        //                    }

        //                    //Step 3.0: Get All [Feed] of [Page]
        //                    strQuery = String.Format(Constants.Facebook_Option._x_yz, itemFB_Page.iFID, Constants.Facebook_Param.feed, Constants.Facebook_Param.feed_param);
        //                    do
        //                    {
        //                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                        objFB_Feed = new FacebookEO.Feed();
        //                        objFB_Feed = (FacebookEO.Feed)JsonEx.Json2Object(strJson, objFB_Feed.GetType());

        //                        if (CommonsCheck.Object_OK(objFB_Feed))
        //                        {
        //                            if (CommonsCheck.ListObject_OK(objFB_Feed.data))
        //                            {
        //                                foreach (Facebook_EXEO.Feed.data itemFB_Feed_Data in objFB_Feed.data)
        //                                {
        //                                    //Step 4.0: Get Item [Post]
        //                                    strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._xy, StringEx.Split_iFB_ID(itemFB_Feed_Data.id, 1), "?fields=id,from,message"));
        //                                    objFB_Post = new FacebookEO.Post();
        //                                    objFB_Post = (FacebookEO.Post)JsonEx.Json2Object(strJson, objFB_Post.GetType());
        //                                    if (objFB_Post == null)
        //                                        continue;
        //                                    //Step 4.1: Insert/Update [Post]
        //                                    _PostEO = new PostEO(Convert.ToInt64(objFB_Post.id), Convert.ToInt64(objFB_Page.id), objFB_Post.from, objFB_Post.message, Convert.ToDateTime(objFB_Post.updated_time), 0);
        //                                    (new PostDAO()).Insert_Update_Delete(_PostEO, ConstEx.Insert_Update_Delete.Insert);

        //                                    //Step 4.2: Insert/Update [Like] of [Post]
        //                                    strQuery = String.Format(Constants.Facebook_Option._x_yz, objFB_Post.id, Constants.Facebook_Param.likes, Constants.Facebook_Param.likes_param);
        //                                    do
        //                                    {
        //                                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                                        objFB_Like = new FacebookEO.Likes();
        //                                        objFB_Like = (FacebookEO.Likes)JsonEx.Json2Object(strJson, objFB_Like.GetType());
        //                                        if (objFB_Like != null && CommonsCheck.ListObject_OK(objFB_Like.data))
        //                                        {
        //                                            foreach (Facebook_EXEO.Likes.data itemlike in objFB_Like.data)
        //                                            {
        //                                                _LikeEO = new LikeEO(Convert.ToInt64(objFB_Post.id), Convert.ToInt64(itemlike.id), itemFB_Page.iFID, itemlike.name, 0);
        //                                                (new LikeDAO()).Insert_Update_Delete(_LikeEO, ConstEx.Insert_Update_Delete.Insert);
        //                                            }
        //                                        }
        //                                        if (CommonsCheck.Object_OK(objFB_Like) && CommonsCheck.Object_OK(objFB_Like.paging) && !String.IsNullOrEmpty(objFB_Like.paging.next))
        //                                        {
        //                                            isNextPage = true;
        //                                            strQuery = StringEx.Trim(objFB_Like.paging.next).Substring(32);
        //                                        }
        //                                        else
        //                                            isNextPage = false;
        //                                    } while (isNextPage);

        //                                    //Step 4.3: Insert/Update [Comment] of [Post]
        //                                    strQuery = String.Format(Constants.Facebook_Option._x_yz, objFB_Post.id, "comments", "?fields=created_time,from,message,can_remove,like_count,user_likes,id,comment_count&limit=100");
        //                                    do
        //                                    {
        //                                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                                        objFB_Comment = new FacebookEO.Comments();
        //                                        objFB_Comment = (FacebookEO.Comments)JsonEx.Json2Object(strJson, objFB_Comment.GetType());
        //                                        if (objFB_Comment != null && CommonsCheck.ListObject_OK(objFB_Comment.data))
        //                                        {
        //                                            foreach (Facebook_EXEO.Comments.data itemComment in objFB_Comment.data)
        //                                            {
        //                                                _CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemComment.id, 1), itemFB_Page.iFID, Convert.ToInt64(objFB_Post.id), 0, Convert.ToInt64(itemComment.from.id), itemComment.from.name, Convert.ToDateTime(itemComment.created_time), itemComment.message, itemComment.can_remove, itemComment.like_count, "", itemComment.user_likes, itemComment.comment_count, 0);
        //                                                (new CommentDAO()).Insert_Update_Delete(_CommentEO, ConstEx.Insert_Update_Delete.Insert);
        //                                                if (itemComment.comment_count > 0)
        //                                                {
        //                                                    //Step 4.4: Insert/Update [Reply] of [Comment]
        //                                                    strQuery = String.Format(Constants.Facebook_Option._x_yz, itemComment.id, "comments", "?fields=created_time,from,message,can_remove,like_count,user_likes,id,comment_count&limit=100");
        //                                                    do
        //                                                    {
        //                                                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                                                        objFB_Reply = new FacebookEO.Comments();
        //                                                        objFB_Reply = (FacebookEO.Comments)JsonEx.Json2Object(strJson, objFB_Reply.GetType());
        //                                                        if (objFB_Reply != null && CommonsCheck.ListObject_OK(objFB_Reply.data))
        //                                                        {
        //                                                            foreach (Facebook_EXEO.Comments.data itemReply in objFB_Reply.data)
        //                                                            {
        //                                                                _CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemReply.id, 1), itemFB_Page.iFID, Convert.ToInt64(objFB_Post.id), StringEx.Split_iFB_ID(itemComment.id, 1), Convert.ToInt64(itemReply.from.id), itemReply.from.name, Convert.ToDateTime(itemReply.created_time), itemReply.message, itemReply.can_remove, itemReply.like_count, "", itemReply.user_likes, 0, 0);
        //                                                                (new CommentDAO()).Insert_Update_Delete(_CommentEO, ConstEx.Insert_Update_Delete.Insert);
        //                                                            }
        //                                                        }
        //                                                        if (CommonsCheck.Object_OK(objFB_Reply) && CommonsCheck.Object_OK(objFB_Reply.paging) && !String.IsNullOrEmpty(objFB_Reply.paging.next))
        //                                                        {
        //                                                            isNextPage = true;
        //                                                            strQuery = StringEx.Trim(objFB_Reply.paging.next).Substring(32);
        //                                                        }
        //                                                        else
        //                                                            isNextPage = false;
        //                                                    } while (isNextPage);
        //                                                }
        //                                            }
        //                                        }
        //                                        if (CommonsCheck.Object_OK(objFB_Comment) && CommonsCheck.Object_OK(objFB_Comment.paging) && !String.IsNullOrEmpty(objFB_Comment.paging.next))
        //                                        {
        //                                            isNextPage = true;
        //                                            strQuery = StringEx.Trim(objFB_Comment.paging.next).Substring(32);
        //                                        }
        //                                        else
        //                                            isNextPage = false;
        //                                    } while (isNextPage);
        //                                }
        //                            }
        //                        }
        //                        if (CommonsCheck.Object_OK(objFB_Feed) && CommonsCheck.Object_OK(objFB_Feed.paging) && !String.IsNullOrEmpty(objFB_Feed.paging.next))
        //                        {
        //                            isNextPage = true;
        //                            strQuery = StringEx.Trim(objFB_Feed.paging.next).Substring(32);
        //                        }
        //                        else
        //                            isNextPage = false;
        //                    } while (isNextPage);
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        sRet = ex.ToString();
        //    }
        //    bWaiting = false;
        //    return sRet;
        //}




        ///// <summary>
        ///// Các công việc sau sẽ được tự động thực hiện sau 3 phút:
        /////     - Gọi hàm gửi mail khi có người đăng nhập, bình luận ở mục hỏi đáp.
        /////     - Gọi hàm kiểm tra thay đổi và tạo lại các file: sitemap.html, sitemap.xml, rss.xml.
        ///// </summary>
        ///// <param name="source"></param>
        ///// <param name="e"></param>
        //public static String Job_Frequency_3m_SQLite(object source, System.Timers.ElapsedEventArgs e)
        //{
        //    //File.ReadAllText("C:\\Users\\Administrator\\Desktop\\FB\\feed.txt");//
        //    String sRet = "OK";
        //    try
        //    {
        //        if (!bWaiting)
        //        {
        //            bWaiting = true;

        //            //Step 1.0: Init
        //            FacebookClient FBClient = new FacebookClient();
        //            FBClient.AppId = OtherEx.getAppSettings("Facebook_AppId");
        //            FBClient.AppSecret = OtherEx.getAppSettings("Facebook_AppSecret");
        //            //FBClient.Version = OtherEx.getAppSettings("Version");

        //            //Step 1.1: Declare
        //            Boolean isNextPage = false;

        //            String strJson = "";
        //            String strQuery = "";

        //            List<OptionEXEO> lstFB_Page = new List<OptionEXEO>();
        //            FacebookEO.Feed objFB_Feed;
        //            FacebookEO.Post objFB_Post;
        //            FacebookEO.User objFB_User;
        //            Facebook_EXEO.User.accounts objFB_User_accounts;
        //            FacebookEO.Page objFB_Page;
        //            FacebookEO.Likes objFB_Like;
        //            FacebookEO.Comments objFB_Comment;
        //            FacebookEO.Comments objFB_Reply;

        //            AccountEO _AccountEO = new AccountEO();
        //            _AccountEO.PK_iAID = 1;
        //            PageEO _PageEO;
        //            PostEO _PostEO;
        //            LikeEO _LikeEO;
        //            CommentEO _CommentEO;
        //            OptionEO _OptionEO;
        //            UserEO _UserEO;


        //            //Step 1.2: Get token
        //            //if (String.IsNullOrEmpty(_AccountEO.sFToken))
        //            //    throw new Exception("Facebook token is null.");
        //            //FBClient.AccessToken = _AccountEO.sFToken;



        //            //Step 2.0: Get info [Account] in Database
        //            _AccountEO = (new Account_EXDAO()).SelectItem(_AccountEO);
        //            FBClient.AccessToken = _AccountEO.sFToken;

        //            //Step 2.1: Get info [User] in Facebook
        //            strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._x_yz, Constants.Facebook_Param.me, Constants.Facebook_Param.user_param, ""));
        //            objFB_User = new FacebookEO.User();
        //            objFB_User = (FacebookEO.User)JsonEx.Json2Object(strJson, objFB_User.GetType());
        //            if (CommonsCheck.Object_OK(objFB_User))
        //            {
        //                _UserEO = new UserEO(Convert.ToInt64(objFB_User.id), objFB_User.first_name, objFB_User.last_name, objFB_User.link, objFB_User.middle_name, objFB_User.name, objFB_User.timezone, Convert.ToDateTime(objFB_User.updated_time), objFB_User.verified, 0, true);
        //                (new User_EXDAO()).Insert_Update_Delete(_UserEO, ConstEx.Insert_Update_Delete.Insert);

        //                //Step 2.2: Get all [Page] of [User]
        //                strQuery = String.Format(Constants.Facebook_Option._x_yz, Constants.Facebook_Param.me, Constants.Facebook_Param.user_accounts, "");
        //                do
        //                {
        //                    strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                    objFB_User_accounts = new Facebook_EXEO.User.accounts();
        //                    objFB_User_accounts = (Facebook_EXEO.User.accounts)JsonEx.Json2Object(strJson, objFB_User_accounts.GetType());
        //                    if (objFB_User_accounts != null && CommonsCheck.ListObject_OK(objFB_User_accounts.data))
        //                        foreach (var itemFB_User in objFB_User_accounts.data)
        //                        {
        //                            _OptionEO = new OptionEO(Constants.Option_tid.user_page, Convert.ToInt64(objFB_User.id), Convert.ToInt64(itemFB_User.id), objFB_User.name, itemFB_User.name, itemFB_User.access_token, true, DateTime.Now, DateTime.Now, 0, true);
        //                            (new Option_EXDAO()).Insert_Update_Delete(_OptionEO, ConstEx.Insert_Update_Delete.Insert);
        //                        }
        //                    if (CommonsCheck.Object_OK(objFB_User_accounts) && CommonsCheck.Object_OK(objFB_User_accounts.paging) && !String.IsNullOrEmpty(objFB_User_accounts.paging.next))
        //                    {
        //                        isNextPage = true;
        //                        strQuery = StringEx.Trim(objFB_User_accounts.paging.next).Substring(32);
        //                    }
        //                    else
        //                        isNextPage = false;
        //                } while (isNextPage);
        //            }

        //            //Step 2.3: Get token [Page] in Database
        //            DataTable dt = (new Option_EXDAO()).SelectBy_tid_lid_rid(Constants.Option_tid.user_page, 0, 0, Constants.Option_iTypeSearch.get_all_page_scan);
        //            lstFB_Page = (List<OptionEXEO>)ConvertEx.ConvertDataTableToListObject<OptionEXEO>(dt, lstFB_Page.GetType());
        //            if (CommonsCheck.ListObject_OK(lstFB_Page))
        //            {
        //                foreach (OptionEXEO itemFB_Page in lstFB_Page)
        //                {
        //                    if (String.IsNullOrEmpty(itemFB_Page.sFToken))
        //                        continue;
        //                    else
        //                        FBClient.AccessToken = itemFB_Page.sFToken;

        //                    //Step 2.4: Insert/Update [Page]
        //                    strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._x, itemFB_Page.iFID));
        //                    objFB_Page = new FacebookEO.Page();
        //                    objFB_Page = (FacebookEO.Page)JsonEx.Json2Object(strJson, objFB_Page.GetType());
        //                    if (CommonsCheck.Object_OK(objFB_Page))
        //                    {
        //                        _PageEO = new PageEO(Convert.ToInt64(objFB_Page.id), objFB_Page.about, ConvertEx.StringFB2DateTime(objFB_Page.birthday, "MM/dd/yyyy"), objFB_Page.can_post, objFB_Page.category, objFB_Page.checkins, objFB_Page.country_page_likes, JsonEx.Object2Json(objFB_Page.cover), objFB_Page.description, objFB_Page.has_added_app, objFB_Page.is_community_page, objFB_Page.is_published, objFB_Page.new_like_count, objFB_Page.likes, objFB_Page.link, objFB_Page.name, objFB_Page.offer_eligible, JsonEx.Object2Json(objFB_Page.parking), objFB_Page.promotion_eligible, objFB_Page.talking_about_count, objFB_Page.unread_message_count, objFB_Page.unread_notif_count, objFB_Page.unseen_message_count, objFB_Page.username, objFB_Page.website, objFB_Page.were_here_count, 0, true);
        //                        (new Page_EXDAO()).Insert_Update_Delete(_PageEO, ConstEx.Insert_Update_Delete.Insert);
        //                    }

        //                    //Step 3.0: Get All [Feed] of [Page]
        //                    strQuery = String.Format(Constants.Facebook_Option._x_yz, itemFB_Page.iFID, Constants.Facebook_Param.feed, Constants.Facebook_Param.feed_param);
        //                    do
        //                    {
        //                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                        objFB_Feed = new FacebookEO.Feed();
        //                        objFB_Feed = (FacebookEO.Feed)JsonEx.Json2Object(strJson, objFB_Feed.GetType());

        //                        if (CommonsCheck.Object_OK(objFB_Feed))
        //                        {
        //                            if (CommonsCheck.ListObject_OK(objFB_Feed.data))
        //                            {
        //                                foreach (Facebook_EXEO.Feed.data itemFB_Feed_Data in objFB_Feed.data)
        //                                {
        //                                    //Step 4.0: Get Item [Post]
        //                                    strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._xy, StringEx.Split_iFB_ID(itemFB_Feed_Data.id, 1), "?fields=id,from,message"));
        //                                    objFB_Post = new FacebookEO.Post();
        //                                    objFB_Post = (FacebookEO.Post)JsonEx.Json2Object(strJson, objFB_Post.GetType());
        //                                    if (objFB_Post == null)
        //                                        continue;
        //                                    //Step 4.1: Insert/Update [Post]
        //                                    _PostEO = new PostEO(Convert.ToInt64(objFB_Post.id), Convert.ToInt64(objFB_Page.id), objFB_Post.from, objFB_Post.message, Convert.ToDateTime(objFB_Post.updated_time), 0, true);
        //                                    (new Post_EXDAO()).Insert_Update_Delete(_PostEO, ConstEx.Insert_Update_Delete.Insert);

        //                                    //Step 4.2: Insert/Update [Like] of [Post]
        //                                    strQuery = String.Format(Constants.Facebook_Option._x_yz, objFB_Post.id, Constants.Facebook_Param.likes, Constants.Facebook_Param.likes_param);
        //                                    do
        //                                    {
        //                                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                                        objFB_Like = new FacebookEO.Likes();
        //                                        objFB_Like = (FacebookEO.Likes)JsonEx.Json2Object(strJson, objFB_Like.GetType());
        //                                        if (objFB_Like != null && CommonsCheck.ListObject_OK(objFB_Like.data))
        //                                        {
        //                                            foreach (Facebook_EXEO.Likes.data itemlike in objFB_Like.data)
        //                                            {
        //                                                _LikeEO = new LikeEO(Convert.ToInt64(objFB_Post.id), Convert.ToInt64(itemlike.id), itemFB_Page.iFID, itemlike.name, 0, true);
        //                                                (new Like_EXDAO()).Insert_Update_Delete(_LikeEO, ConstEx.Insert_Update_Delete.Insert);
        //                                            }
        //                                        }
        //                                        if (CommonsCheck.Object_OK(objFB_Like) && CommonsCheck.Object_OK(objFB_Like.paging) && !String.IsNullOrEmpty(objFB_Like.paging.next))
        //                                        {
        //                                            isNextPage = true;
        //                                            strQuery = StringEx.Trim(objFB_Like.paging.next).Substring(32);
        //                                        }
        //                                        else
        //                                            isNextPage = false;
        //                                    } while (isNextPage);

        //                                    //Step 4.3: Insert/Update [Comment] of [Post]
        //                                    strQuery = String.Format(Constants.Facebook_Option._x_yz, objFB_Post.id, "comments", "?fields=created_time,from,message,can_remove,like_count,user_likes,id,comment_count&limit=100");
        //                                    do
        //                                    {
        //                                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                                        objFB_Comment = new FacebookEO.Comments();
        //                                        objFB_Comment = (FacebookEO.Comments)JsonEx.Json2Object(strJson, objFB_Comment.GetType());
        //                                        if (objFB_Comment != null && CommonsCheck.ListObject_OK(objFB_Comment.data))
        //                                        {
        //                                            foreach (Facebook_EXEO.Comments.data itemComment in objFB_Comment.data)
        //                                            {
        //                                                _CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemComment.id, 1), itemFB_Page.iFID, Convert.ToInt64(objFB_Post.id), 0, Convert.ToInt64(itemComment.from.id), itemComment.from.name, Convert.ToDateTime(itemComment.created_time), itemComment.message, itemComment.can_remove, itemComment.like_count, "", itemComment.user_likes, itemComment.comment_count, 0, true);
        //                                                (new Comment_EXDAO()).Insert_Update_Delete(_CommentEO, ConstEx.Insert_Update_Delete.Insert);
        //                                                if (itemComment.comment_count > 0)
        //                                                {
        //                                                    //Step 4.4: Insert/Update [Reply] of [Comment]
        //                                                    strQuery = String.Format(Constants.Facebook_Option._x_yz, itemComment.id, "comments", "?fields=created_time,from,message,can_remove,like_count,user_likes,id,comment_count&limit=100");
        //                                                    do
        //                                                    {
        //                                                        strJson = OtherEx.Facebook_Graph_API_Get(FBClient, strQuery);
        //                                                        objFB_Reply = new FacebookEO.Comments();
        //                                                        objFB_Reply = (FacebookEO.Comments)JsonEx.Json2Object(strJson, objFB_Reply.GetType());
        //                                                        if (objFB_Reply != null && CommonsCheck.ListObject_OK(objFB_Reply.data))
        //                                                        {
        //                                                            foreach (Facebook_EXEO.Comments.data itemReply in objFB_Reply.data)
        //                                                            {
        //                                                                _CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemReply.id, 1), itemFB_Page.iFID, Convert.ToInt64(objFB_Post.id), StringEx.Split_iFB_ID(itemComment.id, 1), Convert.ToInt64(itemReply.from.id), itemReply.from.name, Convert.ToDateTime(itemReply.created_time), itemReply.message, itemReply.can_remove, itemReply.like_count, "", itemReply.user_likes, 0, 0, true);
        //                                                                (new Comment_EXDAO()).Insert_Update_Delete(_CommentEO, ConstEx.Insert_Update_Delete.Insert);
        //                                                            }
        //                                                        }
        //                                                        if (CommonsCheck.Object_OK(objFB_Reply) && CommonsCheck.Object_OK(objFB_Reply.paging) && !String.IsNullOrEmpty(objFB_Reply.paging.next))
        //                                                        {
        //                                                            isNextPage = true;
        //                                                            strQuery = StringEx.Trim(objFB_Reply.paging.next).Substring(32);
        //                                                        }
        //                                                        else
        //                                                            isNextPage = false;
        //                                                    } while (isNextPage);
        //                                                }
        //                                            }
        //                                        }
        //                                        if (CommonsCheck.Object_OK(objFB_Comment) && CommonsCheck.Object_OK(objFB_Comment.paging) && !String.IsNullOrEmpty(objFB_Comment.paging.next))
        //                                        {
        //                                            isNextPage = true;
        //                                            strQuery = StringEx.Trim(objFB_Comment.paging.next).Substring(32);
        //                                        }
        //                                        else
        //                                            isNextPage = false;
        //                                    } while (isNextPage);
        //                                }
        //                            }
        //                        }
        //                        if (CommonsCheck.Object_OK(objFB_Feed) && CommonsCheck.Object_OK(objFB_Feed.paging) && !String.IsNullOrEmpty(objFB_Feed.paging.next))
        //                        {
        //                            isNextPage = true;
        //                            strQuery = StringEx.Trim(objFB_Feed.paging.next).Substring(32);
        //                        }
        //                        else
        //                            isNextPage = false;
        //                    } while (isNextPage);
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        sRet = ex.ToString();
        //    }
        //    bWaiting = false;
        //    return sRet;
        //}


        //public String Test_Job(Int64 iID)
        //{
        //    List<OptionEXEO> lstFB_Page = new List<OptionEXEO>();
        //    FBEO _FBEO = new FBEO();
        //    FacebookClient FBClient = new FacebookClient();
        //    FBClient.AppId = OtherEx.getAppSettings("Facebook_AppId");
        //    FBClient.AppSecret = OtherEx.getAppSettings("Facebook_AppSecret");
        //    AccountEO _AccountEO = new AccountEO();
        //    _AccountEO.PK_iAID = 1;
        //    _AccountEO = (new Account_EXDAO()).SelectItem(_AccountEO);
        //    FBClient.AccessToken = _AccountEO.sFToken;

        //    //getFacebook_Comment(FBClient, new FBEO(), 0, iID.ToString(), true, true, true);
        //    return "OKK";

        //    getFacebook_Current_User(FBClient, _FBEO, true);
        //    //Step 2.3: Get token [Page] in Database
        //    DataTable dt = (new Option_EXDAO()).SelectBy_tid_lid_rid(Constants.Option_tid.user_page, 0, 0, Constants.Option_iTypeSearch.get_all_page_scan);
        //    lstFB_Page = (List<OptionEXEO>)ConvertEx.ConvertDataTableToListObject<OptionEXEO>(dt, lstFB_Page.GetType());
        //    if (CommonsCheck.ListObject_OK(lstFB_Page))
        //    {
        //        foreach (OptionEXEO itemFB_Page in lstFB_Page)
        //        {
        //            if (String.IsNullOrEmpty(itemFB_Page.sFToken))
        //                continue;
        //            else
        //            {
        //                FBClient.AccessToken = itemFB_Page.sFToken;
        //                if (getFacebook_Page(FBClient, new FBEO(), itemFB_Page.iFID, true, true))
        //                {
        //                    //getFacebook_Feed(FBClient, new FBEO(), itemFB_Page.iFID, true, true, true, true, true);
        //                }

        //            }
        //        }
        //    }
        //    return "OK";
        //}


        //public Boolean getFacebook_Current_User(FacebookClient FBClient, FBEO _FBEO, Boolean isSQLite)
        //{
        //    try
        //    {
        //        //Step 2.1: Get info [User] in Facebook
        //        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._x_yz, Constants.Facebook_Param.me, Constants.Facebook_Param.user_param, ""));
        //        _FBEO.objFB_User = new FacebookEO.User();
        //        _FBEO.objFB_User = (FacebookEO.User)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_User.GetType());
        //        if (CommonsCheck.Object_OK(_FBEO.objFB_User))
        //        {
        //            if (isSQLite)
        //            {
        //                _FBEO._UserEO = new UserEO(Convert.ToInt64(_FBEO.objFB_User.id), _FBEO.objFB_User.first_name, _FBEO.objFB_User.last_name, _FBEO.objFB_User.link, _FBEO.objFB_User.middle_name, _FBEO.objFB_User.name, _FBEO.objFB_User.timezone, Convert.ToDateTime(_FBEO.objFB_User.updated_time), _FBEO.objFB_User.verified, 0, isSQLite);
        //                (new User_EXDAO()).Insert_Update_Delete(_FBEO._UserEO, ConstEx.Insert_Update_Delete.Insert);
        //            }
        //            else
        //            {
        //                _FBEO._UserEO = new UserEO(Convert.ToInt64(_FBEO.objFB_User.id), _FBEO.objFB_User.first_name, _FBEO.objFB_User.last_name, _FBEO.objFB_User.link, _FBEO.objFB_User.middle_name, _FBEO.objFB_User.name, _FBEO.objFB_User.timezone, Convert.ToDateTime(_FBEO.objFB_User.updated_time), _FBEO.objFB_User.verified, 0);
        //                (new UserDAO()).Insert_Update_Delete(_FBEO._UserEO, ConstEx.Insert_Update_Delete.Insert);
        //            }

        //            //Step 2.2: Get all [Page] of [User]
        //            _FBEO.strQuery = String.Format(Constants.Facebook_Option._x_yz, Constants.Facebook_Param.me, Constants.Facebook_Param.user_accounts, "");
        //            do
        //            {
        //                _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, _FBEO.strQuery);
        //                _FBEO.objFB_User_accounts = new Facebook_EXEO.User.accounts();
        //                _FBEO.objFB_User_accounts = (Facebook_EXEO.User.accounts)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_User_accounts.GetType());
        //                if (_FBEO.objFB_User_accounts != null && CommonsCheck.ListObject_OK(_FBEO.objFB_User_accounts.data))
        //                {
        //                    foreach (var itemFB_User in _FBEO.objFB_User_accounts.data)
        //                    {
        //                        if (isSQLite)
        //                        {
        //                            _FBEO._OptionEO = new OptionEO(Constants.Option_tid.user_page, Convert.ToInt64(_FBEO.objFB_User.id), Convert.ToInt64(itemFB_User.id), _FBEO.objFB_User.name, itemFB_User.name, itemFB_User.access_token, true, DateTime.Now, DateTime.Now, 0, isSQLite);
        //                            (new Option_EXDAO()).Insert_Update_Delete(_FBEO._OptionEO, ConstEx.Insert_Update_Delete.Insert);
        //                        }
        //                        else
        //                        {
        //                            _FBEO._OptionEO = new OptionEO(Constants.Option_tid.user_page, Convert.ToInt64(_FBEO.objFB_User.id), Convert.ToInt64(itemFB_User.id), _FBEO.objFB_User.name, itemFB_User.name, itemFB_User.access_token, true, DateTime.Now, DateTime.Now, 0);
        //                            (new OptionDAO()).Insert_Update_Delete(_FBEO._OptionEO, ConstEx.Insert_Update_Delete.Insert);
        //                        }
        //                    }
        //                }
        //                if (CommonsCheck.Object_OK(_FBEO.objFB_User_accounts) && CommonsCheck.Object_OK(_FBEO.objFB_User_accounts.paging) && !String.IsNullOrEmpty(_FBEO.objFB_User_accounts.paging.next))
        //                {
        //                    _FBEO.isNextPage = true;
        //                    _FBEO.strQuery = StringEx.Trim(_FBEO.objFB_User_accounts.paging.next).Substring(32);
        //                }
        //                else
        //                    _FBEO.isNextPage = false;
        //            } while (_FBEO.isNextPage);
        //        }
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(_FBEO), ConstEx.Log_iType.EXCEPTION), false);
        //        return false;
        //    }
        //}

        //public Boolean getFacebook_Page(FacebookClient FBClient, FBEO _FBEO, Int64 page_id, Boolean isGetFeed, Boolean isSQLite)
        //{
        //    try
        //    {
        //        //Step 2.4: Insert/Update [Page]
        //        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._x, page_id));
        //        _FBEO.objFB_Page = new FacebookEO.Page();
        //        _FBEO.objFB_Page = (FacebookEO.Page)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Page.GetType());
        //        if (CommonsCheck.Object_OK(_FBEO.objFB_Page))
        //        {
        //            if (isSQLite)
        //            {
        //                _FBEO._PageEO = new PageEO(Convert.ToInt64(_FBEO.objFB_Page.id), _FBEO.objFB_Page.about, ConvertEx.StringFB2DateTime(_FBEO.objFB_Page.birthday, "MM/dd/yyyy"), _FBEO.objFB_Page.can_post, _FBEO.objFB_Page.category, _FBEO.objFB_Page.checkins, _FBEO.objFB_Page.country_page_likes, JsonEx.Object2Json(_FBEO.objFB_Page.cover), _FBEO.objFB_Page.description, _FBEO.objFB_Page.has_added_app, _FBEO.objFB_Page.is_community_page, _FBEO.objFB_Page.is_published, _FBEO.objFB_Page.new_like_count, _FBEO.objFB_Page.likes, _FBEO.objFB_Page.link, _FBEO.objFB_Page.name, _FBEO.objFB_Page.offer_eligible, JsonEx.Object2Json(_FBEO.objFB_Page.parking), _FBEO.objFB_Page.promotion_eligible, _FBEO.objFB_Page.talking_about_count, _FBEO.objFB_Page.unread_message_count, _FBEO.objFB_Page.unread_notif_count, _FBEO.objFB_Page.unseen_message_count, _FBEO.objFB_Page.username, _FBEO.objFB_Page.website, _FBEO.objFB_Page.were_here_count, 0, isSQLite);
        //                (new Page_EXDAO()).Insert_Update_Delete(_FBEO._PageEO, ConstEx.Insert_Update_Delete.Insert);
        //            }
        //            else
        //            {
        //                _FBEO._PageEO = new PageEO(Convert.ToInt64(_FBEO.objFB_Page.id), _FBEO.objFB_Page.about, ConvertEx.StringFB2DateTime(_FBEO.objFB_Page.birthday, "MM/dd/yyyy"), _FBEO.objFB_Page.can_post, _FBEO.objFB_Page.category, _FBEO.objFB_Page.checkins, _FBEO.objFB_Page.country_page_likes, JsonEx.Object2Json(_FBEO.objFB_Page.cover), _FBEO.objFB_Page.description, _FBEO.objFB_Page.has_added_app, _FBEO.objFB_Page.is_community_page, _FBEO.objFB_Page.is_published, _FBEO.objFB_Page.new_like_count, _FBEO.objFB_Page.likes, _FBEO.objFB_Page.link, _FBEO.objFB_Page.name, _FBEO.objFB_Page.offer_eligible, JsonEx.Object2Json(_FBEO.objFB_Page.parking), _FBEO.objFB_Page.promotion_eligible, _FBEO.objFB_Page.talking_about_count, _FBEO.objFB_Page.unread_message_count, _FBEO.objFB_Page.unread_notif_count, _FBEO.objFB_Page.unseen_message_count, _FBEO.objFB_Page.username, _FBEO.objFB_Page.website, _FBEO.objFB_Page.were_here_count, 0);
        //                (new PageDAO()).Insert_Update_Delete(_FBEO._PageEO, ConstEx.Insert_Update_Delete.Insert);
        //            }
        //            //if (isGetFeed)
        //            //    getFacebook_Feed(FBClient, new FBEO(), page_id, true, true, true, true, false);
        //        }
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(_FBEO), ConstEx.Log_iType.EXCEPTION), false);
        //        return false;
        //    }
        //}

        public Boolean getFacebook_Feed(FacebookClient FBClient, FacebookOptionEO objRequest)
        {
            try
            {
                FBEO _FBEO = new FBEO();
                FacebookOptionEO objRequestTemp;

                //Step 3.0: Get All [Feed] of [Page]
                if (objRequest.type == ConstEx.Facebook_Type.page)
                {
                    _FBEO.strQuery = String.Format(Constants.Facebook_Option._a_bc, objRequest.id_user_page_group, Constants.Facebook_Param.feed, Constants.Facebook_Param.feed_param);
                    do
                    {
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, _FBEO.strQuery);
                        _FBEO.objFB_Feed = new FacebookEO.Feed();
                        _FBEO.objFB_Feed = (FacebookEO.Feed)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Feed.GetType());

                        if (CommonsCheck.Object_OK(_FBEO.objFB_Feed))
                        {
                            if (CommonsCheck.ListObject_OK(_FBEO.objFB_Feed.data))
                            {
                                Parallel.ForEach(_FBEO.objFB_Feed.data, (itemFB_Feed_Data) => { (new Facebook_Object()).Post_Photo_Video_Link_Event_Offer_Note(FBClient, new FacebookOptionEO(Convert.ToInt16(GetListConstantsEx.FindKey_ByValue(ConstEx.Facebook_Type.Get_Facebook_Type_Full(), itemFB_Feed_Data.type, "0")), "", objRequest.id_user_page_group, StringEx.Split_sFB_ID(itemFB_Feed_Data.id, 1), "", objRequest)); });

                                //foreach (Facebook_EXEO.Feed.data itemFB_Feed_Data in _FBEO.objFB_Feed.data)
                                //{
                                //    try
                                //    {
                                //        //Step 4.0: Get Item [Post]
                                //        objRequestTemp = new FacebookOptionEO(Convert.ToInt16(GetListConstantsEx.FindKey_ByValue(ConstEx.Facebook_Type.Get_Facebook_Type_Full(), itemFB_Feed_Data.type, "0")), "", objRequest.id_user_page_group, StringEx.Split_sFB_ID(itemFB_Feed_Data.id, 1), "", objRequest);
                                //        (new Facebook_Object()).Post_Photo_Video_Link_Event_Offer_Note(FBClient, objRequestTemp);
                                //    }
                                //    catch (Exception ex)
                                //    {
                                //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(objRequest), ConstEx.Log_iType.EXCEPTION), false);
                                //    }
                                //}
                            }
                        }
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Feed) && CommonsCheck.Object_OK(_FBEO.objFB_Feed.paging) && !String.IsNullOrEmpty(_FBEO.objFB_Feed.paging.next))
                        {
                            _FBEO.isNextPage = true;
                            _FBEO.strQuery = StringEx.Trim(_FBEO.objFB_Feed.paging.next).Substring(32);
                        }
                        else
                            _FBEO.isNextPage = false;
                    } while (_FBEO.isNextPage);
                    return true;
                }
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(objRequest), ConstEx.Log_iType.EXCEPTION), false);
            }
            return false;
        }

        //public Boolean getFacebook_Post(FacebookClient FBClient, FBEO _FBEO, Int64 page_id, String post_id, Boolean isGetLike, Boolean isGetComment, Boolean isGetReply, Boolean isGetEmail, Boolean isSQLite)
        //{
        //    try
        //    {
        //        //Step 4.0: Get Item [Post]
        //        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._xy, post_id, "?fields=id,from,message"));
        //        _FBEO.objFB_Post = new FacebookEO.Post();
        //        _FBEO.objFB_Post = (FacebookEO.Post)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Post.GetType());
        //        if (_FBEO.objFB_Post == null)
        //            return true;
        //        //Step 4.1: Insert/Update [Post]
        //        if (isSQLite)
        //        {
        //            _FBEO._PostEO = new PostEO(Convert.ToInt64(_FBEO.objFB_Post.id), page_id, _FBEO.objFB_Post.from, _FBEO.objFB_Post.message, Convert.ToDateTime(_FBEO.objFB_Post.updated_time), 0, isSQLite);
        //            (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
        //        }
        //        else
        //        {
        //            _FBEO._PostEO = new PostEO(Convert.ToInt64(_FBEO.objFB_Post.id), page_id, _FBEO.objFB_Post.from, _FBEO.objFB_Post.message, Convert.ToDateTime(_FBEO.objFB_Post.updated_time), 0);
        //            (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
        //        }


        //        //Step 4.2: Insert/Update [Like] of [Post]
        //        //if (isGetLike)
        //        //    getFacebook_Like(FBClient, new FBEO(), page_id, post_id, isSQLite);

        //        //Step 4.3: Insert/Update [Comment] of [Post]
        //        //if (isGetComment)
        //        //    getFacebook_Comment(FBClient, new FBEO(), page_id, post_id, isGetReply, isGetEmail, isSQLite);
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(_FBEO), ConstEx.Log_iType.EXCEPTION), false);
        //        return false;
        //    }
        //}

        public Boolean getFacebook_Like(FacebookClient FBClient, FacebookOptionEO objRequest)
        {
            try
            {
                FBEO _FBEO = new FBEO();

                //Step 4.2: Insert/Update [Like] of [Post]
                _FBEO.strQuery = String.Format(Constants.Facebook_Option._a__b_cd, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.likes, Constants.Facebook_Param.likes_param);
                do
                {
                    _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, _FBEO.strQuery);
                    _FBEO.lstLikeEO = new List<LikeEO>();
                    _FBEO.dtBulk = new DataTable();
                    _FBEO.objFB_Like = new FacebookEO.Likes();
                    _FBEO.objFB_Like = (FacebookEO.Likes)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Like.GetType());
                    if (_FBEO.objFB_Like != null && CommonsCheck.ListObject_OK(_FBEO.objFB_Like.data))
                    {
                        foreach (Facebook_EXEO.Likes.data itemlike in _FBEO.objFB_Like.data)
                        {
                            if (objRequest.isSQLite)
                            {
                                _FBEO._LikeEO = new LikeEO(StringEx.Split_iFB_ID(objRequest.id_status_photo_video_link_event_offer_note, 0), Convert.ToInt64(itemlike.id), Convert.ToInt64(objRequest.id_user_page_group), itemlike.name, 0, objRequest.isSQLite);
                                (new Like_EXDAO()).Insert_Update_Delete(_FBEO._LikeEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._LikeEO = new LikeEO(StringEx.Split_iFB_ID(objRequest.id_status_photo_video_link_event_offer_note, 1), Convert.ToInt64(itemlike.id), Convert.ToInt64(objRequest.id_user_page_group), itemlike.name, 0);
                                //(new LikeDAO()).Insert_Update_Delete(_FBEO._LikeEO, ConstEx.Insert_Update_Delete.Insert);
                                _FBEO.lstLikeEO.Add(_FBEO._LikeEO);
                            }
                        }
                        if (CommonsCheck.ListObject_OK(_FBEO.lstLikeEO))
                        {
                            _FBEO.dtBulk = new DataTable();
                            _FBEO.dtBulk = ConvertEx.ConvertListObjectToDataTable<LikeEO>(_FBEO.lstLikeEO);
                            if (CommonsCheck.DataTable_OK(_FBEO.dtBulk))
                                (new LikeDAO()).Insert_Update_Delete_Bulk(_FBEO.dtBulk, ConstEx.Insert_Update_Delete.Insert);
                        }
                    }
                    if (CommonsCheck.Object_OK(_FBEO.objFB_Like) && CommonsCheck.Object_OK(_FBEO.objFB_Like.paging) && !String.IsNullOrEmpty(_FBEO.objFB_Like.paging.next))
                    {
                        _FBEO.isNextPage = true;
                        _FBEO.strQuery = StringEx.Trim(_FBEO.objFB_Like.paging.next).Substring(32);
                    }
                    else
                        _FBEO.isNextPage = false;
                } while (_FBEO.isNextPage);
                return true;
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(objRequest), ConstEx.Log_iType.EXCEPTION), false);
                return false;
            }
        }

        public Boolean getFacebook_Comment(FacebookClient FBClient, FacebookOptionEO objRequest)
        {
            try
            {
                FBEO _FBEO = new FBEO();
                FacebookOptionEO objRequestTemp;

                //Step 4.3: Insert/Update [Comment] of [Post]
                _FBEO.strQuery = String.Format(Constants.Facebook_Option._a__b_cd, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.comments, Constants.Facebook_Param.comments_param);
                do
                {
                    _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, _FBEO.strQuery);
                    _FBEO.lstCommentEO = new List<CommentEO>();
                    _FBEO.dtBulk = new DataTable();
                    _FBEO.objFB_Comment = new FacebookEO.Comments();
                    _FBEO.objFB_Comment = (FacebookEO.Comments)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Comment.GetType());
                    if (_FBEO.objFB_Comment != null && CommonsCheck.ListObject_OK(_FBEO.objFB_Comment.data))
                    {
                        foreach (Facebook_EXEO.Comments.data itemComment in _FBEO.objFB_Comment.data)
                        {
                            if (objRequest.isSQLite)
                            {
                                _FBEO._CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemComment.id, 1), Convert.ToInt64(objRequest.id_user_page_group), StringEx.Split_iFB_ID(objRequest.id_status_photo_video_link_event_offer_note, 1), 0, Convert.ToInt64(itemComment.from.id), itemComment.from.name, Convert.ToDateTime(itemComment.created_time), itemComment.message, itemComment.can_remove, itemComment.like_count, "", itemComment.user_likes, itemComment.comment_count, 0, objRequest.isSQLite);
                                (new Comment_EXDAO()).Insert_Update_Delete(_FBEO._CommentEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemComment.id, 1), Convert.ToInt64(objRequest.id_user_page_group), StringEx.Split_iFB_ID(objRequest.id_status_photo_video_link_event_offer_note, 1), 0, Convert.ToInt64(itemComment.from.id), itemComment.from.name, Convert.ToDateTime(itemComment.created_time), itemComment.message, itemComment.can_remove, itemComment.like_count, "", itemComment.user_likes, itemComment.comment_count, 0);
                                _FBEO.lstCommentEO.Add(_FBEO._CommentEO);
                                //(new CommentDAO()).Insert_Update_Delete(_FBEO._CommentEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            if (objRequest.isGetEmail)
                            {
                                getFacebook_Email(_FBEO._CommentEO, objRequest.isSQLite);
                            }

                            //Step 4.4: Insert/Update [Reply] of [Comment]
                            if (objRequest.isGetReply && itemComment.comment_count > 0)
                            {
                                objRequestTemp = new FacebookOptionEO(ConstEx.Facebook_Type.reply, "", objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, StringEx.Split_sFB_ID(itemComment.id, 1), objRequest);
                                getFacebook_Reply(FBClient, objRequestTemp);
                            }
                        }
                        if (CommonsCheck.ListObject_OK(_FBEO.lstCommentEO))
                        {
                            _FBEO.dtBulk = new DataTable();
                            _FBEO.dtBulk = ConvertEx.ConvertListObjectToDataTable<CommentEO>(_FBEO.lstCommentEO);
                            if (CommonsCheck.DataTable_OK(_FBEO.dtBulk))
                                (new CommentDAO()).Insert_Update_Delete_Bulk(_FBEO.dtBulk, ConstEx.Insert_Update_Delete.Insert);
                        }
                    }
                    if (CommonsCheck.Object_OK(_FBEO.objFB_Comment) && CommonsCheck.Object_OK(_FBEO.objFB_Comment.paging) && !String.IsNullOrEmpty(_FBEO.objFB_Comment.paging.next))
                    {
                        _FBEO.isNextPage = true;
                        _FBEO.strQuery = StringEx.Trim(_FBEO.objFB_Comment.paging.next).Substring(32);
                    }
                    else
                        _FBEO.isNextPage = false;
                } while (_FBEO.isNextPage);
                return true;
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(objRequest), ConstEx.Log_iType.EXCEPTION), false);
                return false;
            }
        }

        public Boolean getFacebook_Reply(FacebookClient FBClient, FacebookOptionEO objRequest)
        {
            try
            {
                FBEO _FBEO = new FBEO();

                //Step 4.4: Insert/Update [Reply] of [Comment]
                _FBEO.strQuery = String.Format(Constants.Facebook_Option._a__b__c_de, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, objRequest.id_comment, Constants.Facebook_Param.comments, Constants.Facebook_Param.comments_param);
                do
                {
                    _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, _FBEO.strQuery);
                    _FBEO.lstCommentEO = new List<CommentEO>();
                    _FBEO.dtBulk = new DataTable();
                    _FBEO.objFB_Reply = new FacebookEO.Comments();
                    _FBEO.objFB_Reply = (FacebookEO.Comments)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Reply.GetType());
                    if (_FBEO.objFB_Reply != null && CommonsCheck.ListObject_OK(_FBEO.objFB_Reply.data))
                    {
                        foreach (Facebook_EXEO.Comments.data itemReply in _FBEO.objFB_Reply.data)
                        {
                            if (objRequest.isSQLite)
                            {
                                _FBEO._CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemReply.id, 1), Convert.ToInt64(objRequest.id_user_page_group), Convert.ToInt64(objRequest.id_status_photo_video_link_event_offer_note), Convert.ToInt64(objRequest.id_comment), Convert.ToInt64(itemReply.from.id), itemReply.from.name, Convert.ToDateTime(itemReply.created_time), itemReply.message, itemReply.can_remove, itemReply.like_count, "", itemReply.user_likes, 0, 0, objRequest.isSQLite);
                                (new Comment_EXDAO()).Insert_Update_Delete(_FBEO._CommentEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._CommentEO = new CommentEO(StringEx.Split_iFB_ID(itemReply.id, 1), Convert.ToInt64(objRequest.id_user_page_group), Convert.ToInt64(objRequest.id_status_photo_video_link_event_offer_note), Convert.ToInt64(objRequest.id_comment), Convert.ToInt64(itemReply.from.id), itemReply.from.name, Convert.ToDateTime(itemReply.created_time), itemReply.message, itemReply.can_remove, itemReply.like_count, "", itemReply.user_likes, 0, 0);
                                _FBEO.lstCommentEO.Add(_FBEO._CommentEO);
                                //(new CommentDAO()).Insert_Update_Delete(_FBEO._CommentEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            if (objRequest.isGetEmail)
                            {
                                getFacebook_Email(_FBEO._CommentEO, objRequest.isSQLite);
                            }
                        }
                        if (CommonsCheck.ListObject_OK(_FBEO.lstCommentEO))
                        {
                            _FBEO.dtBulk = new DataTable();
                            _FBEO.dtBulk = ConvertEx.ConvertListObjectToDataTable<CommentEO>(_FBEO.lstCommentEO);
                            if (CommonsCheck.DataTable_OK(_FBEO.dtBulk))
                                (new CommentDAO()).Insert_Update_Delete_Bulk(_FBEO.dtBulk, ConstEx.Insert_Update_Delete.Insert);
                        }
                    }
                    if (CommonsCheck.Object_OK(_FBEO.objFB_Reply) && CommonsCheck.Object_OK(_FBEO.objFB_Reply.paging) && !String.IsNullOrEmpty(_FBEO.objFB_Reply.paging.next))
                    {
                        _FBEO.isNextPage = true;
                        _FBEO.strQuery = StringEx.Trim(_FBEO.objFB_Reply.paging.next).Substring(32);
                    }
                    else
                        _FBEO.isNextPage = false;
                } while (_FBEO.isNextPage);
                return true;
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(objRequest), ConstEx.Log_iType.EXCEPTION), false);
                return false;
            }
        }

        public Boolean getFacebook_Email(CommentEO _CommentEO, Boolean isSQLite)
        {
            try
            {
                EmailEO _EmailEO;
                Regex Regex_Email = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase);
                MatchCollection mcEmail = Regex_Email.Matches(_CommentEO.message);
                if (mcEmail != null && mcEmail.Count > 0)
                {
                    foreach (Match mEmail in mcEmail)
                    {
                        if (isSQLite)
                        {
                            _EmailEO = new EmailEO(0, _CommentEO.user_id, StringEx.Trim(_CommentEO.user_name), StringEx.Trim(mEmail.Value), EmailEx.CheckExists_Email(mEmail.Value), isSQLite);
                            (new Email_EXDAO()).Insert_Update_Delete(_EmailEO, ConstEx.Insert_Update_Delete.Insert);
                        }
                        else
                        {
                            _EmailEO = new EmailEO(0, _CommentEO.user_id, StringEx.Trim(_CommentEO.user_name), StringEx.Trim(mEmail.Value), EmailEx.CheckExists_Email(mEmail.Value));
                            (new EmailDAO()).Insert_Update_Delete(_EmailEO, ConstEx.Insert_Update_Delete.Insert);
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(_CommentEO), ConstEx.Log_iType.EXCEPTION), false);
                return false;
            }
        }

        //public String getNewToken_LongLive(FacebookClient FBClient, FBEO _FBEO)
        //{
        //    try
        //    {
        //        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Param.token, FBClient.AppSecret, FBClient.AppId, FBClient.AccessToken));
        //        _FBEO.objFB_Token = new FacebookEO.Token();
        //        _FBEO.objFB_Token = (FacebookEO.Token)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Token.GetType());
        //        return _FBEO.objFB_Token.access_token;
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString() + "\n" + JsonEx.Object2Json(_FBEO), ConstEx.Log_iType.EXCEPTION), false);
        //        return ex.ToString();
        //    }
        //}

        //public String getEmail()
        //{
        //    String sRet = "";
        //    try
        //    {
        //        List<EmailEO> lstEmail;
        //        EmailEO _EmailEO;
        //        Regex Regex_Email = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase);
        //        MatchCollection mcEmail;
        //        Int32 PageSize = 100, RowBegin = 0, RowCount = 24856;
        //        List<CommentEO> lstCmt;
        //        DataTable dtBulk;
        //        do
        //        {
        //            lstEmail = new List<EmailEO>();
        //            dtBulk = (new Comment_EXDAO()).SelectBy_Key_Email(PageSize, RowBegin);
        //            lstCmt = new List<CommentEO>();
        //            lstCmt = (List<CommentEO>)ConvertEx.ConvertDataTableToListObject<CommentEO>(dtBulk, lstCmt.GetType());
        //            if (CommonsCheck.ListObject_OK(lstCmt))
        //            {
        //                foreach (CommentEO item in lstCmt)
        //                {
        //                    mcEmail = Regex_Email.Matches(item.message);
        //                    if (mcEmail != null && mcEmail.Count > 0)
        //                    {
        //                        foreach (Match mEmail in mcEmail)
        //                        {
        //                            _EmailEO = new EmailEO(0, item.user_id, StringEx.Trim(item.user_name), StringEx.Trim(mEmail.Value), EmailEx.CheckExists_Email(mEmail.Value));
        //                            lstEmail.Add(_EmailEO);
        //                            //(new EmailDAO()).Insert_Update_Delete(_EmailEO, ConstEx.Insert_Update_Delete.Insert);
        //                        }
        //                    }
        //                }
        //                if (CommonsCheck.ListObject_OK(lstEmail))
        //                {
        //                    dtBulk = ConvertEx.ConvertListObjectToDataTable<EmailEO>(lstEmail);
        //                    if (CommonsCheck.DataTable_OK(dtBulk))
        //                        (new EmailDAO()).Insert_Update_Delete_Bulk(dtBulk, ConstEx.Insert_Update_Delete.Insert);
        //                }
        //            }
        //            RowBegin = RowBegin + PageSize;
        //        } while (RowCount >= RowBegin);
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
        //        sRet = ex.ToString();
        //    }
        //    return sRet;
        //}






        //public void evttimerAutoScan(object source, System.Timers.ElapsedEventArgs e)
        //{
        //    Timer timer = (Timer)source;
        //    try
        //    {
        //        timer.Stop();
        //        Int16 iTop_Limit = Convert.ToInt16(Convert.ToInt16(OtherEx.getAppSettings("Top_Limit", "6")) - iThread_Count);
        //        DataTable dt = (new RequestDAO()).SelectBy_iStatus(FacebookApp.SharedLibraries.Constants.Request_iStatus.received, FacebookApp.SharedLibraries.Constants.Request_iStatus.processing, iTop_Limit);
        //        if (CommonsCheck.DataTable_OK(dt))
        //        {
        //            List<RequestEO> lstRes = new List<RequestEO>();
        //            lstRes = (List<RequestEO>)ConvertEx.ConvertDataTableToListObject<RequestEO>(dt, lstRes.GetType());
        //            if (CommonsCheck.ListObject_OK(lstRes))
        //            {
        //                if (iThread_Count < Convert.ToInt16(OtherEx.getAppSettings("Top_Limit", "6")))
        //                {
        //                    iThread_Count = Convert.ToInt16(iThread_Count + lstRes.Count);
        //                    Parallel.ForEach(lstRes, (item) => { Thread_Request_Api(item); });
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
        //    }
        //    finally
        //    {
        //        timer.Start();
        //    }
        //}

        //public void Thread_Request_Api(RequestEO objInput)
        //{
        //    Boolean isSuccess = false;
        //    try
        //    {
        //        FacebookClient FBClient = new FacebookClient();
        //        FBClient.AppId = OtherEx.getAppSettings("Facebook_AppId");
        //        FBClient.AppSecret = OtherEx.getAppSettings("Facebook_AppSecret");
        //        FBClient.AccessToken = "CAAXaKZCf3qnkBAB0GyTyozEBwHq2DEEhokYxZCNmlRq05FynZAzVwBFvvGES68TuTnJ2IO32XQuC46BZC1clN7bId4CsBEDgnnmYzM6JBq60njv7uAA0dNLCbwbbLpfch0qIlzzHuuurDZBabmoCDcFsK8bv6Dx7diTVWu9JxQvvWvwhBkeMp";
        //        FacebookApp.SharedLibraries.ScheduleJobs ctl = new FacebookApp.SharedLibraries.ScheduleJobs();
        //        Boolean isSQLite = false;
        //        switch (objInput.iType)
        //        {
        //            case ConstEx.Facebook_Type.user:
        //                ctl.getFacebook_Current_User(FBClient, new FBEO(), isSQLite);
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.page:
        //                ctl.getFacebook_Page(FBClient, new FBEO(), Convert.ToInt64(objInput.sFID), true, isSQLite);
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.group:
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.feed:
        //                //ctl.getFacebook_Feed(FBClient, new FBEO(), Convert.ToInt64(objInput.sFID), objInput.bLike, objInput.bComment, objInput.bReply, objInput.bEmail, isSQLite);
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.status:
        //                ctl.getFacebook_Post(FBClient, new FBEO(), 0, objInput.sFID, objInput.bLike, objInput.bComment, objInput.bReply, objInput.bEmail, isSQLite);
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.photo:
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.video:
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.events:
        //                isSuccess = true;
        //                break;
        //            case ConstEx.Facebook_Type.like:
        //                isSuccess = true;
        //                //ctl.getFacebook_Like(FBClient, new FBEO(), 0, objInput.sFID, isSQLite);
        //                break;
        //            case ConstEx.Facebook_Type.comment:
        //                isSuccess = true;
        //                //ctl.getFacebook_Comment(FBClient, new FBEO(), 0, objInput.sFID, objInput.bReply, objInput.bEmail, isSQLite);
        //                break;
        //            case ConstEx.Facebook_Type.reply:
        //                isSuccess = true;
        //                //ctl.getFacebook_Reply(FBClient, new FBEO(), 0, objInput.sFID, 0, objInput.bEmail, isSQLite);
        //                break;
        //            default:
        //                isSuccess = false;
        //                break;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
        //        isSuccess = false;
        //    }
        //    iThread_Count--;
        //    try
        //    {
        //        objInput.tSuccess = DateTime.Now;
        //        if (isSuccess)
        //        {
        //            objInput.iStatus = FacebookApp.SharedLibraries.Constants.Request_iStatus.success;
        //        }
        //        else
        //            objInput.iStatus = FacebookApp.SharedLibraries.Constants.Request_iStatus.error;
        //        (new RequestDAO()).Insert_Update_Delete(objInput, ConstEx.Insert_Update_Delete.Update);
        //    }
        //    catch (Exception ex)
        //    {
        //        (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
        //    }
        //}


        public class Facebook_Object
        {
            /// <summary>
            /// User - Page - Group
            /// </summary>
            /// <param name="FBClient">Facebook.FacebookClient</param>
            /// <param name="id">username/id User - Page - Group</param>
            /// <returns></returns>
            public FacebookOptionEO User_Page_Group(FacebookClient FBClient, FacebookOptionEO objRequest)
            {
                try
                {
                    FBEO _FBEO = new FBEO();

                    objRequest.id_user_page_group = StringEx.Trim(objRequest.id_user_page_group);
                    if (String.IsNullOrEmpty(objRequest.id_user_page_group))
                        return null;
                    if (!StringEx.IsNumeric(objRequest.id_user_page_group, TypeCode.Int64))
                    {
                        String iTemp = OtherEx.Facebook_UserName_To_UserID(objRequest.id_user_page_group).ToString();
                        if (StringEx.IsNumeric(iTemp, TypeCode.Int64) && Convert.ToInt64(iTemp) > 0)
                            objRequest.id_user_page_group = iTemp;
                    }
                    //Check is User
                    if (objRequest.type == ConstEx.Facebook_Type.user || (objRequest.type <= 0 && _FBEO.objFB_User == null))
                    {
                        //Step 2.1: Get info [User] in Facebook
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._ab, objRequest.id_user_page_group, Constants.Facebook_Param.user_param));
                        _FBEO.objFB_User = new FacebookEO.User();
                        _FBEO.objFB_User = (FacebookEO.User)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_User.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_User))
                        {
                            if (objRequest.isSQLite)
                            {
                                _FBEO._UserEO = new UserEO(Convert.ToInt64(_FBEO.objFB_User.id), _FBEO.objFB_User.first_name, _FBEO.objFB_User.last_name, _FBEO.objFB_User.link, _FBEO.objFB_User.middle_name, _FBEO.objFB_User.name, _FBEO.objFB_User.timezone, Convert.ToDateTime(_FBEO.objFB_User.updated_time), _FBEO.objFB_User.verified, 0, objRequest.isSQLite);
                                (new User_EXDAO()).Insert_Update_Delete(_FBEO._UserEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._UserEO = new UserEO(Convert.ToInt64(_FBEO.objFB_User.id), _FBEO.objFB_User.first_name, _FBEO.objFB_User.last_name, _FBEO.objFB_User.link, _FBEO.objFB_User.middle_name, _FBEO.objFB_User.name, _FBEO.objFB_User.timezone, Convert.ToDateTime(_FBEO.objFB_User.updated_time), _FBEO.objFB_User.verified, 0);
                                (new UserDAO()).Insert_Update_Delete(_FBEO._UserEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.user;
                            objRequest.name = StringEx.Trim(_FBEO._UserEO.name, "N/A");
                            objRequest.id_user_page_group = Convert.ToString(_FBEO._UserEO.id);
                        }
                    }

                    //Check is Page
                    if (objRequest.type == ConstEx.Facebook_Type.page || (objRequest.type <= 0 && _FBEO.objFB_User == null))
                    {
                        //Step 2.4: Insert/Update [Page]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._ab, objRequest.id_user_page_group, Constants.Facebook_Param.page_param));
                        _FBEO.objFB_Page = new FacebookEO.Page();
                        _FBEO.objFB_Page = (FacebookEO.Page)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Page.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Page))
                        {
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PageEO = new PageEO(Convert.ToInt64(_FBEO.objFB_Page.id), _FBEO.objFB_Page.about, ConvertEx.StringFB2DateTime(_FBEO.objFB_Page.birthday, "MM/dd/yyyy"), _FBEO.objFB_Page.can_post, _FBEO.objFB_Page.category, _FBEO.objFB_Page.checkins, _FBEO.objFB_Page.country_page_likes, JsonEx.Object2Json(_FBEO.objFB_Page.cover), _FBEO.objFB_Page.description, _FBEO.objFB_Page.has_added_app, _FBEO.objFB_Page.is_community_page, _FBEO.objFB_Page.is_published, _FBEO.objFB_Page.new_like_count, _FBEO.objFB_Page.likes, _FBEO.objFB_Page.link, _FBEO.objFB_Page.name, _FBEO.objFB_Page.offer_eligible, JsonEx.Object2Json(_FBEO.objFB_Page.parking), _FBEO.objFB_Page.promotion_eligible, _FBEO.objFB_Page.talking_about_count, _FBEO.objFB_Page.unread_message_count, _FBEO.objFB_Page.unread_notif_count, _FBEO.objFB_Page.unseen_message_count, _FBEO.objFB_Page.username, _FBEO.objFB_Page.website, _FBEO.objFB_Page.were_here_count, 0, objRequest.isSQLite);
                                (new Page_EXDAO()).Insert_Update_Delete(_FBEO._PageEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PageEO = new PageEO(Convert.ToInt64(_FBEO.objFB_Page.id), _FBEO.objFB_Page.about, ConvertEx.StringFB2DateTime(_FBEO.objFB_Page.birthday, "MM/dd/yyyy"), _FBEO.objFB_Page.can_post, _FBEO.objFB_Page.category, _FBEO.objFB_Page.checkins, _FBEO.objFB_Page.country_page_likes, JsonEx.Object2Json(_FBEO.objFB_Page.cover), _FBEO.objFB_Page.description, _FBEO.objFB_Page.has_added_app, _FBEO.objFB_Page.is_community_page, _FBEO.objFB_Page.is_published, _FBEO.objFB_Page.new_like_count, _FBEO.objFB_Page.likes, _FBEO.objFB_Page.link, _FBEO.objFB_Page.name, _FBEO.objFB_Page.offer_eligible, JsonEx.Object2Json(_FBEO.objFB_Page.parking), _FBEO.objFB_Page.promotion_eligible, _FBEO.objFB_Page.talking_about_count, _FBEO.objFB_Page.unread_message_count, _FBEO.objFB_Page.unread_notif_count, _FBEO.objFB_Page.unseen_message_count, _FBEO.objFB_Page.username, _FBEO.objFB_Page.website, _FBEO.objFB_Page.were_here_count, 0);
                                (new PageDAO()).Insert_Update_Delete(_FBEO._PageEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.page;
                            objRequest.name = StringEx.Trim(_FBEO._PageEO.name, "N/A");
                            objRequest.id_user_page_group = Convert.ToString(_FBEO._PageEO.id);
                        }
                    }

                    //Check is Group
                    if (objRequest.type == ConstEx.Facebook_Type.group || (objRequest.type <= 0 && _FBEO.objFB_Page == null))
                    {
                        //Step 2.4: Insert/Update [Page]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._ab, objRequest.id_user_page_group, Constants.Facebook_Param.group_param));
                        _FBEO.objFB_Group = new FacebookEO.Group();
                        _FBEO.objFB_Group = (FacebookEO.Group)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Group.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Group))
                        {
                            //if (objRequest.isSQLite)
                            //{
                            //    _FBEO._PageEO = new PageEO(Convert.ToInt64(_FBEO.objFB_Page.id), _FBEO.objFB_Page.about, ConvertEx.StringFB2DateTime(_FBEO.objFB_Page.birthday, "MM/dd/yyyy"), _FBEO.objFB_Page.can_post, _FBEO.objFB_Page.category, _FBEO.objFB_Page.checkins, _FBEO.objFB_Page.country_page_likes, JsonEx.Object2Json(_FBEO.objFB_Page.cover), _FBEO.objFB_Page.description, _FBEO.objFB_Page.has_added_app, _FBEO.objFB_Page.is_community_page, _FBEO.objFB_Page.is_published, _FBEO.objFB_Page.new_like_count, _FBEO.objFB_Page.likes, _FBEO.objFB_Page.link, _FBEO.objFB_Page.name, _FBEO.objFB_Page.offer_eligible, JsonEx.Object2Json(_FBEO.objFB_Page.parking), _FBEO.objFB_Page.promotion_eligible, _FBEO.objFB_Page.talking_about_count, _FBEO.objFB_Page.unread_message_count, _FBEO.objFB_Page.unread_notif_count, _FBEO.objFB_Page.unseen_message_count, _FBEO.objFB_Page.username, _FBEO.objFB_Page.website, _FBEO.objFB_Page.were_here_count, 0, objRequest.isSQLite);
                            //    (new Page_EXDAO()).Insert_Update_Delete(_FBEO._PageEO, ConstEx.Insert_Update_Delete.Insert);
                            //}
                            //else
                            //{
                            //    _FBEO._PageEO = new PageEO(Convert.ToInt64(_FBEO.objFB_Page.id), _FBEO.objFB_Page.about, ConvertEx.StringFB2DateTime(_FBEO.objFB_Page.birthday, "MM/dd/yyyy"), _FBEO.objFB_Page.can_post, _FBEO.objFB_Page.category, _FBEO.objFB_Page.checkins, _FBEO.objFB_Page.country_page_likes, JsonEx.Object2Json(_FBEO.objFB_Page.cover), _FBEO.objFB_Page.description, _FBEO.objFB_Page.has_added_app, _FBEO.objFB_Page.is_community_page, _FBEO.objFB_Page.is_published, _FBEO.objFB_Page.new_like_count, _FBEO.objFB_Page.likes, _FBEO.objFB_Page.link, _FBEO.objFB_Page.name, _FBEO.objFB_Page.offer_eligible, JsonEx.Object2Json(_FBEO.objFB_Page.parking), _FBEO.objFB_Page.promotion_eligible, _FBEO.objFB_Page.talking_about_count, _FBEO.objFB_Page.unread_message_count, _FBEO.objFB_Page.unread_notif_count, _FBEO.objFB_Page.unseen_message_count, _FBEO.objFB_Page.username, _FBEO.objFB_Page.website, _FBEO.objFB_Page.were_here_count, 0);
                            //    (new PageDAO()).Insert_Update_Delete(_FBEO._PageEO, ConstEx.Insert_Update_Delete.Insert);
                            //}
                            objRequest.type = ConstEx.Facebook_Type.group;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Group.name, "N/A");
                            objRequest.id_user_page_group = Convert.ToString(_FBEO.objFB_Group.id);
                        }
                    }

                    if (!String.IsNullOrEmpty(objRequest.name) && objRequest.isGetPost)
                        (new ScheduleJobs()).getFacebook_Feed(FBClient, objRequest);
                    return objRequest;
                }
                catch (Exception ex)
                {
                    (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
                }
                return new FacebookOptionEO();
            }

            /// <summary>
            /// post (Status, Photo, Video, Link, Event, Offer, Note)
            /// </summary>
            /// <param name="FBClient">Facebook.FacebookClient</param>
            /// <param name="id">id: [User - Page - Group]_[Status, Photo, Video, Link, Event, Offer, Note]</param>
            /// <returns></returns>
            public FacebookOptionEO Post_Photo_Video_Link_Event_Offer_Note(FacebookClient FBClient, FacebookOptionEO objRequest)
            {
                try
                {
                    FBEO _FBEO = new FBEO();

                    if (String.IsNullOrEmpty(StringEx.Trim(objRequest.id_user_page_group)) || String.IsNullOrEmpty(StringEx.Trim(objRequest.id_status_photo_video_link_event_offer_note)))
                        return null;
                    else
                        if (!StringEx.IsNumeric(objRequest.id_user_page_group, TypeCode.Int64))
                        {
                            FacebookOptionEO objRequestTemp = new FacebookOptionEO(ConstEx.Facebook_Type.unknown, "", objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, objRequest.id_comment, objRequest);
                            objRequestTemp = User_Page_Group(FBClient, objRequestTemp);
                            objRequest.id_user_page_group = objRequestTemp.id_user_page_group;
                        }

                    //Check is Status
                    if (objRequest.type == ConstEx.Facebook_Type.status || (objRequest.type <= 0 && _FBEO.objFB_Post == null))
                    {
                        //Step 4.0: Get Item [Status]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._a__bc, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.status_param));
                        _FBEO.objFB_Post = new FacebookEO.Post();
                        _FBEO.objFB_Post = (FacebookEO.Post)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Post.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Post))
                        {
                            //Step 4.1: Insert/Update [Status]
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Post.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), _FBEO.objFB_Post.from, _FBEO.objFB_Post.message, Convert.ToDateTime(_FBEO.objFB_Post.updated_time), ConstEx.Facebook_Type.status, 0, objRequest.isSQLite);
                                (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Post.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), _FBEO.objFB_Post.from, _FBEO.objFB_Post.message, Convert.ToDateTime(_FBEO.objFB_Post.updated_time), ConstEx.Facebook_Type.status, 0);
                                (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.status;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Post.message, "N/A");
                        }
                    }

                    //Check is Photo
                    if (objRequest.type == ConstEx.Facebook_Type.photo || (objRequest.type <= 0 && _FBEO.objFB_Post == null))
                    {
                        //Step 4.0: Get Item [Photo]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._a__bc, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.photo_param));
                        _FBEO.objFB_Photo = new FacebookEO.Photo();
                        _FBEO.objFB_Photo = (FacebookEO.Photo)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Photo.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Photo))
                        {
                            //Step 4.1: Insert/Update [Photo]
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Photo.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), "", Convert.ToDateTime(_FBEO.objFB_Photo.updated_time), ConstEx.Facebook_Type.photo, 0, objRequest.isSQLite);
                                (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Photo.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), "", Convert.ToDateTime(_FBEO.objFB_Photo.updated_time), ConstEx.Facebook_Type.photo, 0);
                                (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.photo;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Photo.link, "N/A");
                        }
                    }

                    //Check is Video
                    if (objRequest.type == ConstEx.Facebook_Type.video || (objRequest.type <= 0 && _FBEO.objFB_Post == null))
                    {
                        //Step 4.0: Get Item [Video]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._a__bc, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.video_param));
                        //_FBEO.strJson = File.ReadAllText("C:\\json.txt");
                        _FBEO.objFB_Video = new FacebookEO.Video();
                        _FBEO.objFB_Video = (FacebookEO.Video)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Video.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Video))
                        {
                            //Step 4.1: Insert/Update [Video]
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Video.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), _FBEO.objFB_Video.from, _FBEO.objFB_Video.name, Convert.ToDateTime(_FBEO.objFB_Video.updated_time), ConstEx.Facebook_Type.video, 0, objRequest.isSQLite);
                                (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Video.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), _FBEO.objFB_Video.from, _FBEO.objFB_Video.name, Convert.ToDateTime(_FBEO.objFB_Video.updated_time), ConstEx.Facebook_Type.video, 0);
                                (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.video;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Video.name, "N/A");
                        }
                    }

                    //Check is Link
                    if (objRequest.type == ConstEx.Facebook_Type.link || (objRequest.type <= 0 && _FBEO.objFB_Post == null))
                    {
                        //Step 4.0: Get Item [Link]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._a__bc, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.link_param));
                        _FBEO.objFB_Link = new FacebookEO.Link();
                        _FBEO.objFB_Link = (FacebookEO.Link)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Link.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Link))
                        {
                            //Step 4.1: Insert/Update [Link]
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Link.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), "", Convert.ToDateTime(_FBEO.objFB_Link.updated_time), ConstEx.Facebook_Type.link, 0, objRequest.isSQLite);
                                (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Link.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), "", Convert.ToDateTime(_FBEO.objFB_Link.updated_time), ConstEx.Facebook_Type.link, 0);
                                (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.link;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Link.message, "N/A");
                        }
                    }

                    //Check is Event
                    if (objRequest.type == ConstEx.Facebook_Type.events || (objRequest.type <= 0 && _FBEO.objFB_Post == null))
                    {
                        //Step 4.0: Get Item [Event]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._a__bc, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.event_param));
                        _FBEO.objFB_Event = new FacebookEO.Event();
                        _FBEO.objFB_Event = (FacebookEO.Event)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Event.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Event))
                        {
                            //Step 4.1: Insert/Update [Event]
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Event.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), "", Convert.ToDateTime(_FBEO.objFB_Event.updated_time), ConstEx.Facebook_Type.events, 0, objRequest.isSQLite);
                                (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Event.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), "", Convert.ToDateTime(_FBEO.objFB_Event.updated_time), ConstEx.Facebook_Type.events, 0);
                                (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.events;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Event.story, "N/A");
                        }
                    }

                    //Check is Offer
                    if (objRequest.type == ConstEx.Facebook_Type.offer || (objRequest.type <= 0 && _FBEO.objFB_Post == null))
                    {
                        //Step 4.0: Get Item [Offer]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._a__bc, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.offer_param));
                        _FBEO.objFB_Offer = new FacebookEO.Offer();
                        _FBEO.objFB_Offer = (FacebookEO.Offer)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Offer.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Offer))
                        {
                            //Step 4.1: Insert/Update [Offer]
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Offer.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), _FBEO.objFB_Offer.message, Convert.ToDateTime(_FBEO.objFB_Offer.updated_time), ConstEx.Facebook_Type.offer, 0, objRequest.isSQLite);
                                (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Offer.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), new FacebookEO.User(), _FBEO.objFB_Offer.message, Convert.ToDateTime(_FBEO.objFB_Offer.updated_time), ConstEx.Facebook_Type.offer, 0);
                                (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.offer;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Offer.story, "N/A");
                        }
                    }

                    //Check is Note
                    if (objRequest.type == ConstEx.Facebook_Type.note || (objRequest.type <= 0 && _FBEO.objFB_Post == null))
                    {
                        //Step 4.0: Get Item [Note]
                        _FBEO.strJson = OtherEx.Facebook_Graph_API_Get(FBClient, String.Format(Constants.Facebook_Option._a__bc, objRequest.id_user_page_group, objRequest.id_status_photo_video_link_event_offer_note, Constants.Facebook_Param.note_param));
                        _FBEO.objFB_Note = new FacebookEO.Note();
                        _FBEO.objFB_Note = (FacebookEO.Note)JsonEx.Json2Object(_FBEO.strJson, _FBEO.objFB_Note.GetType());
                        if (CommonsCheck.Object_OK(_FBEO.objFB_Note))
                        {
                            //Step 4.1: Insert/Update [Note]
                            if (objRequest.isSQLite)
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Note.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), _FBEO.objFB_Note.from, _FBEO.objFB_Note.message, Convert.ToDateTime(_FBEO.objFB_Note.updated_time), ConstEx.Facebook_Type.note, 0, objRequest.isSQLite);
                                (new Post_EXDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            else
                            {
                                _FBEO._PostEO = new PostEO(StringEx.Split_iFB_ID(_FBEO.objFB_Note.id, 1), StringEx.Split_iFB_ID(objRequest.id_user_page_group, 0), _FBEO.objFB_Note.from, _FBEO.objFB_Note.message, Convert.ToDateTime(_FBEO.objFB_Note.updated_time), ConstEx.Facebook_Type.note, 0);
                                (new PostDAO()).Insert_Update_Delete(_FBEO._PostEO, ConstEx.Insert_Update_Delete.Insert);
                            }
                            objRequest.type = ConstEx.Facebook_Type.offer;
                            objRequest.name = StringEx.Trim(_FBEO.objFB_Note.story, "N/A");
                        }
                    }

                    if (objRequest.isGetLike)
                        (new ScheduleJobs()).getFacebook_Like(FBClient, objRequest);
                    if (objRequest.isGetComment)
                        (new ScheduleJobs()).getFacebook_Comment(FBClient, objRequest);
                    return objRequest;
                }
                catch (Exception ex)
                {
                    (new Logs()).WriteLog_To_DB(new ThangNM_LIB.EO.LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
                }
                return null;
            }
        }
    }
}